<?php
/**
 * IndexModel
 *
 */
namespace Home\Model;
use Think\Model;
class IndexModel extends Model {
    private $http;
    private $url;

    public function __construct(){
        $this->url = 'api.bangbanggou.com';
        $this->version = 'v1';
        $this->base_url = 'http://' . $this->url . '/' . $this->version . '/';
        $this->mod_http = new \Home\Model\HttpModel();
        
    }

    /**
     * 首页列表
     *
     */
    public function api_list($page=1, $limit=3)
    {
        $api_url = $this->base_url . 'list';
        $params = array('page'=>$page, 'limit'=>$limit);
        $result = $this->mod_http->post($api_url, $params);
        return $result;
    }


    /**
     * 提问发布
     *
     */
    public function api_publish($title, $intro)
    {
        $api_url = $this->base_url . 'publish';
        $params = array('title'=>$title, 'intro'=>$intro);
        $result = $this->mod_http->post($api_url, $params);
        return $result;
    }


    /**
     * 评论发布
     *
     */
    public function api_comment($id, $content)
    {
        $api_url = $this->base_url . 'comment';
        $params = array('id'=>$id, 'content'=>$content);
        $result = $this->mod_http->post($api_url, $params);
        return $result;
    }

    /**
     * 帖子详情页
     *
     */
    public function api_info($id)
    {
        $api_url = $this->base_url . 'info';
        $params = array('id'=>$id);
        $result = $this->mod_http->post($api_url, $params);
        return $result;
    }

}
